<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <style>
        html, body {
            background-color: #f8f8f8;
        }
        .confirm_order,.continus_pay,.confirm_catch{
            bottom: 0px;
            position: absolute;
            background: white;
            width: 100%;
            padding: 8px 0;
            display: none;
        }
        .confirm_delivery{
            background: #e62442;
            color: white;
            overflow: hidden;
            margin-left: 10%;
            width: 80%;
            height: 34px;
            text-align: center;
            line-height: 34px;
            font-size: 16px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
	<div id="header"></div>
    <div class="continus_pay">
        <div class="confirm_delivery" tapmode onclick="fnToPay();">继续支付</div>
    </div>
    <div class=" confirm_catch">
        <div class="confirm_delivery" tapmode onclick="fnToCatch();">确认骑手取货</div>
    </div>
    <div class=" confirm_order">
        <div class="confirm_delivery" tapmode onclick="fnToConfirm();">确认送达</div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript">
    apiready = function(){
        id = api.pageParam.id;
        status = api.pageParam.status;
        _h = api.frameHeight;
        /*if(status == 0){
            // 未支付
            $('.continus_pay').show();
            _h = api.frameHeight - 50;
        }else if(status == 4){
            _h = api.frameHeight - 50;
            $('.confirm_order').show();
        }else if(status == 2 || status == 3){
            _h = api.frameHeight - 50;
            $('.confirm_catch').show();
        }else{
        }*/
        $api.fixStatusBar(header);
        api.openFrame({
            name: 'package_order_frame',
            url: 'package_order_frame.html',
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: _h
            },
            bounces: true,
            pageParam:{
                id:id,
                status:status
            }
        });
    };

    function fnToCatch () {
        user = $api.getStorage('user_data');
        api.ajax({
            url: rootPath+'/api/order/confirm_staff_catch_order',
            method: 'get',
            data: {
                values: { 
                    order_id: id,
                    uid:user.id,
                    token:user.token
                },
            }
        }, function(ret, err) {
            if (ret && ret.status == 201) {
                toast(ret.msg);
            } else if (ret && ret.status == 200){
                api.sendEvent({
                    name: 'orderChangeEvent',
                });
                toast('确认成功',300);
            }
        });
    };

    function fnHideConfirmButton () {
        $('.confirm_order').hide();
        api.setFrameAttr({
            name: 'package_order_frame',
            rect: {
                h: api.frameHeight
            },
        });
    };

    function fnToConfirm () {
        var jsfun = 'confirmDelivery();';
        api.execScript({
            frameName:'package_order_frame',
            script: jsfun
        });
    };

    function fnToPay () {
        var jsfun = 'continusPay();';
        api.execScript({
            frameName:'package_order_frame',
            script: jsfun
        });
    };


</script>
</html>